<template>
  <div>
    <!-- <el-button type="text" @click="dialogFormVisible = true">新增</el-button> -->
    <el-dialog title="新增配置" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="配置名称" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="配置内容" :label-width="formLabelWidth">
          <el-input v-model="form.value" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button @click="yes">确定新增</el-button>
   
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { updateconfig } from "@/api/yxSystemConfig";
export default {
  data() {
    return {
      dialogFormVisible: false,
      form: {
        name: "",
        value: "",
        delivery: false,
      },
      formLabelWidth: "120px",
    };
  },
  created() {

  },
  methods: {
   
    opendialog() {
      this.dialogFormVisible = true;
    },
    
     yes() {
  updateconfig([{configName:this.form.name,value:this.form.value,configLabel:this.form.value}])
      .then((res) => {
        console.log(res, "updata");
        this.$message({
          message: "恭喜你，新增成功",
          type: "success",
        });
        setTimeout(() => {
          this.dialogFormVisible = false;
        }, 1000);
        this.$router.go(0)
      })
      .catch((err) => {
        this.$message.error("错了哦，这是一条错误消息");
        console.log(err.response.data.message);
      });
        // })
  
  },
  },
 
};
</script>

<style>
</style>